﻿@model Inscriptionem.Areas.Inscriptionem.Models.Views.CategoryViewModel

@{
    ViewBag.Title = "Inscriptionem » Categories » Edit Category";
    Layout = "../Shared/Layout.cshtml";

    ViewBag.CurrentPage = "Categories";

    string message = string.Empty;

    switch (Model.Error)
    {
        case Inscriptionem.Areas.Inscriptionem.Models.Enums.CategoryError.CategoryEmpty:
            {
                message = "Please enter Category.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.CategoryError.CategorySectionEmpty:
            {
                message = "Please enter Category Section.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.CategoryError.CategoryAlreadyExists:
            {
                message = "Category already exists, try another one.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.CategoryError.OrderNotValid:
            {
                message = "Please enter valid order, a positive number.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.CategoryError.OrderAlreadyInUse:
            {
                message = "Entered order already in use by another Category, please enter different value.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.CategoryError.Other:
            {
                message = "Unknown error occurred, please try again.";
                break;
            }
    }
}

<div class="outer" id="contentwrap">
    @{Html.RenderPartial("NavigationMenu");}
    <div class="postcont">
		<div id="content">
            <div class="post type-post status-publish format-standard hentry">
                <h2 class="title">Edit Category</h2>
                <div class="postdate-single error-message">@message</div>
                <hr />
                <form method="post" action="/Inscriptionem/Category/Edit">
                    <input type="hidden" name="ID" value="@Model.ID" />
				    <div class="entry">
                        <p>Order <input type="text" name="Order" value="@Model.Order" /></p>
                        <p>Category <input type="text" name="Name" value="@Model.Name" /></p>
                        <p>Section
                            <select name="Section">
                            @foreach (var language in Model.Languages)
                            {
                                if (language.Sections.Any())
                                {
                                <text>
                                <optgroup label="@language.Name / @language.LocalizedName">
                                    @foreach (var section in language.Sections.OrderBy(s => s.Order))
                                    {
                                        <text>
                                        <option value="@(section.ID)" @(Model.Section == section.ID ? "selected" : string.Empty)>@(section.Name) / @(section.LocalizedName)</option>
                                        </text>
                                    }
                                </optgroup>
                                </text>
                                }
                            }
                            </select>
                        </p>
	                </div>

                    <input type="reset" value="Reset" />&nbsp;|&nbsp;<input type="submit" value="Save" />
                </form>
			</div>
        </div>
	</div>	
</div>
